import { project } from '../../../Data'
import { API_LIST } from '../../../Api/Api'
import { ProjectList } from '../Common/Conversion'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    ModDataButton,
    DelDataButton,
    OpenSelection,
    OpenTwoRouter,
    CommonButton,
} from '../Common/options'
import { DataSynchronization } from '../Common/Conversion'

const { client_id } = project[window.location.hostname]
const projectUuidStatus = ['jszx']

export const AuditRecordses = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    const centNameOptions = await DataSynchronization()
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenSelection
                OptionsEvent={OptionsEvent}
                title="批量审核"
                data={{
                    type: 'SelectionTemplateRecordses',
                    url: 'posAuditRecordsesUpdateReviewStatus',
                }}
            />,
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,

            <CommonButton
                OptionsEvent={OptionsEvent}
                title="上传数据"
                type="primary"
                data={{
                    type: 'SelectModalAddDates',
                    actionRef,
                    options: centNameOptions,
                    label: '上传位置',
                    url: 'posBCCenterPushPushOrganizationState',
                }}
            />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'AuditRecordses' },
            commonTableList.uuid,
            {
                ...commonTableList.projectUuid,
                valueEnum: await ProjectList(),
                width: 300,
                hideInAdded: !projectUuidStatus.includes(client_id),
                hideInModify: !projectUuidStatus.includes(client_id),
                hideInTable: !projectUuidStatus.includes(client_id),
                hideInSearch: !projectUuidStatus.includes(client_id),
            },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'businessType',
                title: '业务类型',
                valueType: 'select',
                valueEnum: {
                    仪器试验业务: '仪器试验业务',
                    非仪器试验业务: '非仪器试验业务',
                    无人航拍: '无人航拍',
                    安全巡检: '安全巡检',
                    监理月报: '监理月报',
                    工程质量运行情况报告: '工程质量运行情况报告',
                    质量月报: '质量月报',
                },
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'existsFlag',
                title: '业务是否存在',
                valueType: 'select',
                valueEnum: { 是: '是', 否: '否' },
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'businessDate',
                title: '业务日期',
                valueType: 'Date',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'reason',
                title: '原因',
                valueType: 'textarea',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'reviewStatus',
                title: '审核状态',
                valueType: 'select',
                valueEnum: { 通过: '通过', 未通过: '未通过' },
                rules: true,
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'reviewer',
                title: '审核人',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'reviewDate',
                title: '审核日期',
                valueType: 'Date',
                rules: true,
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            commonTableList.BeginStatDate,
            commonTableList.EndStatDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="TwoTwo"
                            title="附件管理"
                            twoTitle="评分说明附件"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'AttachmentDetails',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
